<?php
namespace app\yunda\model;

use think\Model;
use traits\model\SoftDelete;

/**
 * 积分商品分类表
 * @package app\yunda\model
 */
class Goods_type extends Model
{
    use SoftDelete;
    protected $table = 'dp_yd_goods_type';
    protected $autoWriteTimestamp = true;

    //获取所有商品分类
    public static function get_list_goodType($type='home')
    {
        $map=[
            'status'=>1,
        ];
        $order='sort desc,id desc';
        $list=[];
        if($type=='home'){
            $list=self::where($map)->order($order)->paginate();
        }
        if($type=='admin'){
            $list=self::where($map)->order($order)->column('id,good_type_name');
            if(empty($list))$list[0]='暂无分类';
        }
        return $list;
    }
    
}
